<template>
  <el-dialog :title="title" :close-on-click-modal="false" :fullscreen="true" :visible.sync="visible"
    :before-close="cancel" class="JNPF-dialog JNPF-dialog_center" lock-scroll width="50%">
    <el-row class="JNPF-common-search-box" :gutter="16">
      <el-form @submit.native.prevent ref="elForm" :model="dataForm" :rules="rules">
        
        <el-col :span="8">
            <el-form-item label="学校名称">
              <el-select v-model="dataForm.FHOME" placeholder="请选择" >
                <el-option
                  v-for="item in options1"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

         <el-col :span="8">
            <el-form-item label="年级名称">
              <el-select v-model="dataForm.FPARENTNO" placeholder="请选择" >
                <el-option
                  v-for="item in options2"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="班级名称">
              <el-select v-model="dataForm.FCLASS" placeholder="请选择" >
                <el-option
                  v-for="item in options3"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="8">
          <el-form-item label="身份证号" prop="FCATNO">
            <el-input v-model="dataForm.FCATNO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="学生姓名" prop="FCATNAME">
            <el-input v-model="dataForm.FCATNAME"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="学年届" prop="FYEAR">
            <el-input v-model="dataForm.FYEAR"   />
          </el-form-item>
        </el-col>

         <el-col :span="16">
          <el-form-item label="备注信息" prop="FMEMO">
            <el-input v-model="dataForm.FMEMO"   />
          </el-form-item>
        </el-col>

        <el-col :span="8">
            <el-form-item label="性别">
              <el-select v-model="dataForm.FSEX" placeholder="请选择" >
                <el-option
                  v-for="item in options4"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>

        <el-col :span="5">
          <el-form-item label="">
            <el-button type="success" icon="el-icon-plus" @click="insert">联系人</el-button>
            <el-button type="primary" :loading="loading">返回</el-button>
          </el-form-item>
        </el-col>
      </el-form>
    </el-row>

    <el-table :data="list" border stripe>
      <el-table-column label="操作" width="80">
        <template slot-scope="scope">
          <el-button slot="reference" icon="el-icon-delete" style="color: red" @click="shopdate(scope.$index)"
            type="text">删除</el-button>
        </template>
      </el-table-column>
      <el-table-column prop="FENTRYID" label="序号" width="85"></el-table-column>
      <el-table-column prop="FTYPE" label="家庭关系" ></el-table-column>
      <el-table-column prop="FCATNAME" label="姓名" ></el-table-column>
      <el-table-column prop="FTEL" label="联系电话" ></el-table-column>
    </el-table>
    <StudqueryFcuston ref="StudqueryFcuston" @confirm="shoplist" />
  </el-dialog>
</template>
<script>
  import StudqueryFcuston from "@/components/StudqueryFcuston/StudqueryFcuston.vue"
  import jnpf from "@/utils/jnpf"
  export default {
    components: { StudqueryFcuston },
    props: {
      formationlist: {
        type: Array,
        default: [],
      },
    },
    data() {
      return {
        title: "新增",
        insertorupdate: true,
        dataForm: {
          FHOME :"闵行春申小学",
          FYEAR:2024,
          FPARENTNO: "一年级",
          FCLASS:"1班",
          FMEMO: "",
          FCATNO: "241001",
          FCATNAME: "曹植",
          FSEX:"男",
          FNOTE: ""
        },
        rules: {
          FUSER: [
            { required: true, message: '请输入请购人员', trigger: 'blur' },
          ],
          FMEMO: [
            { required: true, message: '请输入请购理由', trigger: 'blur' },
          ],
        },
        list: [{  "FENTRYID":1,
                  "FTYPE": "父亲",
                  "FCATNO": "3001",
                  "FCATNAME": "曹操",
                  "FTEL":"135****9034",
                  "FMEMO": ""
                },
                { "FENTRYID":2,
                  "FTYPE": "兄长",
                  "FCATNO": "3002",
                  "FCATNAME": "曹丕",
                  "FTEL":"177****7654",
                  "FMEMO": ""
                }],
        loading: false,
        visible: false,

        //所属校区选择数据
        options1: [{
          value: '20E01',
          label: '闵行春申小学'
        }, {
          value: '20E02',
          label: '闵行莘城中学'
        }, {
          value: '20N01',
          label: '闵行莘松中学'
        }, {
          value: '20N02',
          label: '闵行莘庄中学'
        }],

        //
        options2: [{
          value: '1',
          label: '一年级'
        }, {
          value: '2',
          label: '二年级'
        }, {
          value: '3',
          label: '三年级'
        }, {
          value: '4',
          label: '四年级'
        }, {
          value: '5',
          label: '五年级'
        }
        ],

        //
        options3: [{
          value: '1',
          label: '1班'
        }, {
          value: '2',
          label: '2班'
        }, {
          value: '3',
          label: '3班'
        }],

        //
        options3: [{
          value: '1',
          label: '男'
        }, {
          value: '2',
          label: '女'
        }],
        
      };
    },
    created() {
    },
    mounted() { },
    methods: {
      //
      init(FBILLNO) {
        this.dataForm.FBILLNO = FBILLNO;
        if (this.dataForm.FBILLNO) {
          this.title = "修改"
          this.insertorupdate = false;
        }
        else {
          this.title = "新增"
          this.dataForm.FBILLNO = "K" + Math.floor(Math.random() * 10000000) + 1;
          this.insertorupdate = true;
        }
        this.visible = true;
      },
      insert() {
        this.$refs.StudqueryFcuston.open();
      },
      shoplist(data) {
        data.forEach(item => {
          this.list.push({
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "1"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "曹操"
          },{
            FBILLNO: this.dataForm.FBILLNO
            , FENTRYID: "2"
            , FYEAR: 2024
            , FGRADE: "大一"
            , FCLASS: "化学系1班"
            , FSTUDNAME: "刘备"
          })
        });
      },
      //
      cancel() {
        this.$refs.elForm.resetFields();
        this.list = [];
        this.visible = false;
      },
    },
  };
</script>